/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package headquarters.statistics;

import com.vividsolutions.jts.geom.Point;
import java.io.Serializable;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Type;

/**
 *
 * @author Marcin Bełzowski
 */
@Entity
public class Position implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

//    @Column(nullable=false)
//    private double x;
//    @Column(nullable=false)
//    private double y;
//    @Column (nullable=false)
     @Lob
    @Column(name = "the_geom")
   @Type(type = "org.hibernatespatial.GeometryUserType")
    private Point point;
    @Temporal(TemporalType.TIMESTAMP)
    private Calendar dateSent;

    public Position() {
    }

    public Position( Point p, Calendar dateSent) {
        
        this.point = p;
        this.dateSent = dateSent;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Calendar getDateSent() {
        return dateSent;
    }

    public void setDateSent(GregorianCalendar dateSent) {
        this.dateSent = dateSent;
    }

    public Point getPoint(){
        return point;
    }
    public void setPoint(Point p){
        this.point = p;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 79 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 79 * hash + (this.point != null ? this.point.hashCode() : 0);
        hash = 79 * hash + (this.dateSent != null ? this.dateSent.hashCode() : 0);
        return hash;
    }

//    public double getX() {
//        return x;
//    }
//
//    public void setX(double x) {
//        this.x = x;
//    }
//
//    public double getY() {
//        return y;
//    }
//
//    public void setY(double y) {
//        this.y = y;
//    }

    
    

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Position other = (Position) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if (!this.point.equals(other.point)) return false;
        if (this.dateSent != other.dateSent && (this.dateSent == null || !this.dateSent.equals(other.dateSent))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return id + " " + "(" + point.getX() + "," + point.getY() + ")" + dateSent.toString();
    }
}
